import { Component, OnInit, Output, EventEmitter } from '@angular/core';

import { RemoveTableService } from '../../../../public/serve/remove-table/remove-table.service';
import { HintsService } from '../../../../public/serve/hints/hints.service';
import { InitService } from '../../../../public/serve/init/init.service';
import { CudTableService } from 'app/public/serve/cud-table/cud-table.service';
import { Service } from '../../../../server/server';

import { appProductUrl } from '../../../product.url';
import { product } from '../../../product.data';
import {appSynonymUrl} from '../../../../synonym/synonym.url';

declare var $: any;

@Component({
	selector: 'app-product-indexing-task-content-audit',
	templateUrl: './product-indexing-task-content-audit.component.html'
})
export class ProductIndexingTaskContentAuditComponent implements OnInit {
	auditData: any;
	@Output() auditEvent = new EventEmitter<void>();
	checkStatus:any = '200';
	constructor(public initService: InitService,
		private server: Service,
		private request: CudTableService,
		private hintsService: HintsService) { }

	ngOnInit() {
	}

	setAuditData(data) {
		this.auditData = data;
	}

	_checkStatus(status:any){
		this.checkStatus = status;
	}

	/**
	 * 产品内容审核
	 */
	_onSubmit(info: any) {
		info.token = product.retrieval.token;
		info.id = this.auditData.id;
		info.productId = this.auditData.productId;
		info.taskId = this.auditData.taskId;
		info.updateBy = this.server.getuserName();
		info.checkStatus = this.checkStatus;
		this.request.postRequest(this.server.baseUrl +appProductUrl.updateTaskProductCheckStatus, info).then(res => {
			if (res.result_code == '0000') {
				this.auditEvent.emit();
			}
			this.hintsService.messages(res.message, res.result_code);
			$("#productTastContentAudit").modal("hide");
			return;
		}).catch((err: any) => {
			this.hintsService.messages('error', 'error');
			$("#productTastContentAudit").modal("hide");
			return;
		});
	}
}
